package com.project.seckill.bo;

import com.project.seckill.constant.CodeMessage;

import java.io.Serializable;

/**
 * Created by yachao on 2018/6/24.
 */
public class JsonEntity<T> implements Serializable {

    private int code;
    private String message;
    private T data;

    {
        this.code = CodeMessage.SUCCESS.getCode();
        this.message = CodeMessage.SUCCESS.getMessage();
    }

    public JsonEntity() {
    }

    public JsonEntity(T data) {
        this.data = data;
    }

    public JsonEntity(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public JsonEntity(CodeMessage codeMessage) {
        this.code = codeMessage.getCode();
        this.message = codeMessage.getMessage();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "JsonEntity{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
